package com.yunmang.adapter;

import android.content.Context;
import android.support.v7.widget.CardView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.TextView;

import com.yunmang.R;
import com.yunmang.entity.MyItemInfoBean;

import java.util.List;

/**
 * 作者 : bean on 2017/4/10/0010.
 * 注释 :
 */
public class MyHomeAdapter2 extends BaseAdapter {
    private List<MyItemInfoBean> list;
    private Context context;

    public MyHomeAdapter2(Context context, List<MyItemInfoBean> gvListItem2) {
        this.context = context;
        this.list = gvListItem2;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyHolder holder;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.gv_home_item2, null);
            holder = new MyHolder();
            holder.tv_count = (TextView) convertView.findViewById(R.id.tv_count);
            holder.tv_today_count = (TextView) convertView.findViewById(R.id.tv_today_count);
            holder.ll_background = (LinearLayout) convertView.findViewById(R.id.ll_background);
            convertView.setTag(holder);
        } else {
            holder = (MyHolder) convertView.getTag();
        }
        holder.ll_background.setBackgroundResource(list.get(position).getBackground());
        holder.tv_count.setText(list.get(position).getTitle());
        holder.tv_today_count.setText(list.get(position).getDetail());
        return convertView;
    }


    private class MyHolder {
        public TextView tv_count;
        public TextView tv_today_count;
        public LinearLayout ll_background;
    }
}